package cn.christ.com.mobilesafe.receiver;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;

import cn.christ.com.mobilesafe.common.utils.SPUtils;
import cn.christ.com.mobilesafe.constant.Constants;

public class BootReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		try {
			// 1 开机启动，检查sim是否发生改变
			// 2 获取保存sim信息，再获取现在sim的信息，对象比对
			String localSim = (String) SPUtils.get(Constants.SJFD_BIND_SIM,"");
			TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
			String sim = tm.getSimSerialNumber()+"dd";
			if (!sim.equals(localSim)) {
				// 3 假如不一致，获取安全号码，
				String safeNum = (String) SPUtils.get(Constants.SJFD_SAFE_NUM,"");
				// 4 发生短信给安全号码
				SmsManager.getDefault().sendTextMessage(safeNum, null, "wo shi shi xiao xiao xiao tou tou tou", null,
						null);
			}

		} catch (Exception e) {

		}

	}

}
